// <editor-fold defaultstate="collapsed" desc="GNU GPLv3 Header">
/*
 * File:   Main.java
 *
 * Copyright (C) 2013 Robert Antoni Buj Gelonch <rbuj@uoc.edu>
 * Copyright (C) 2013 David Megias Jimenez <dmegias@uoc.edu>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
// </editor-fold>
package readwritewave;

// <editor-fold defaultstate="collapsed" desc="imports">
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
// </editor-fold>

/**
 * The main class.
 *
 * @author Robert Antoni Buj Gelonch <rbuj@uoc.edu>
 * @version 1.0
 * @since 2013-08-04
 */
public class Main {

    /**
     * The main function.
     *
     * When the program begins running, the system calls the
     * function main. Firstly, the function reads an audio wave file specified
     * in the first execution argument, and loads its content into the memory.
     * This was done by calling the WavFile constructor with a correct wave
     * audio file path.
     * <p>
     * Secondly, the function stores the audio information loaded in memory into
     * the specified file path.
     *
     * @param args the command line arguments
     * 
     * @author Robert Antoni Buj Gelonch <rbuj@uoc.edu>
     * @version 1.0
     * @since 2013-08-04
     */
    public static void main(String[] args) {
        if (args.length < 2) {
            System.err.println("Must supply filenames:");
            System.err.println("java -jar readwriteWave.jar input.wav output.wav");
            System.exit(1);
        }

        String strSrcFilePath = args[0];
        String strDstFilePath = args[1];

        try {
            WaveFile wavefile = new WaveFile(strSrcFilePath);
            wavefile.save(strDstFilePath);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
